package com.hualan.sfzy.controller.course;

import com.hualan.sfzy.entity.course.CourseEvaluate;
import com.hualan.sfzy.service.course.CourseEvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class CourseEvaluateController {
    @Autowired
    private CourseEvaluateService courseEvaluateService;
    @PostMapping("/courseEvaluate")
    public String add(@RequestBody CourseEvaluate courseEvaluate) {
        return courseEvaluateService.add(courseEvaluate)>0 ? "success" :"fail";
    }
    @PutMapping("/courseEvaluate")
    public String edit(@RequestBody CourseEvaluate courseEvaluate) {
        return courseEvaluateService.edit(courseEvaluate)>0 ? "success" :"fail";
    }
    @DeleteMapping("/courseEvaluate/{id}")
    public String remove(@PathVariable int id) {
        return courseEvaluateService.remove(id)>0 ? "success" :"fail";
    }
    @DeleteMapping("/courseEvaluate")
    public String removeBatch(Integer[] ids) {
        return courseEvaluateService.removeBatch(ids)>0 ? "success" :"fail";
    }
    @GetMapping("/courseEvaluate")
    public List<CourseEvaluate> find() {
        return courseEvaluateService.find();
    }
    @GetMapping("/courseEvaluate/{id}")
    public CourseEvaluate findById(@PathVariable int id) {
        return courseEvaluateService.findById(id);
    }
    @GetMapping("/courseEvaluate/page")
    public Object findPage(
            @RequestParam(value = "pageNum",defaultValue = "1",required = false)
            Integer pageNum,
            @RequestParam(value = "pageSize",defaultValue = "5",required = false)
            Integer pageSize, CourseEvaluate courseEvaluate) {
        return courseEvaluateService.findPage(pageNum, pageSize, courseEvaluate);
    }
}

